<?php
namespace app\serverfund\service\integral;
use app\manage\service\ApiBase;
/**
 * @author:      李颖
 * @DateTime:    2017-09-20 13:57:32
 * @Description: 积分派发服务
 */
class IntegralDistribute extends ApiBase
{
	protected $integralDistributeValidate = '\app\serverfund\validate\IntegralDistribute';
    protected $integralDistributeLogic = '\app\serverfund\logic\IntegralDistribute';

    /*添加资金派发积分的记录*/
    public function add(): array 
    {
    	$data = $this->haveIssetReceiveData(['app_id'=>0, 'other_app_read'=>'', 'is_public'=>' ', 'fund_type'=>' ', 'fund'=>0, 'integral'=>0, 'remark'=>'', 'system_user_name'=>' '], ['']);
        if($data['integral'] != 1){
            return verify_err(null, '设置规则必须为多少资产派发一个积分');
        }
    	return $this->stepRun($data, 'add', '', $this->integralDistributeValidate, $this->integralDistributeLogic);
    }

    /*获取某应用下的最新一条积分派发记录*/
    public function getOneNew(): array 
    {
    	$data = $this->haveIssetReceiveData(['app_id'=>0]);
    	return $this->stepRun($data, 'getOneNew', '', $this->integralDistributeValidate, $this->integralDistributeLogic);
    }

    /*后台获取积分派发记录列表*/
    public function list(): array 
    {
        $data = $this->haveIssetReceiveData(['app_id'=>0, 'page'=>1, 'listRows'=>15]);
        return $this->stepRun($data, 'list');
    }

}